< previous page page_642 next page >

Page 642
Despite the fact that online information systems always promise a "paperless" office, everyone likes to have printed reports. For some Visual Basic programmers, reporting has always been the most frustrating part of developing an application. If you create your own reporting functions using Print and other graphics methods, you tend to spend a lot of time and effort that could be better spent in other areas. At the other extreme is using a third-party reporting add-in, which is quicker to implement but raises a whole bunch of other issues, including additional cost and DLL distribution requirements.
In Visual Basic 6.0, Microsoft has added a new way to include reporting in your application: the Data Report. Data Reports enable you to easily display a print preview screen, with print and export buttons, from an ADO data source. All you have to do is provide the data and report layout. In addition to this new reporting tool, Visual Basic also supports Crystal Reports, a popular reporting tool that has been packaged with Visual Basic for quite some time now. Crystal Reports, a product of Seagate software, provides an easy way to graphically design and distribute reports.
In this chapter, you examine both of these reporting tools and learn how to use them in your applications.
Creating a Simple Report
The Data Report is known as an ActiveX Designer, meaning that it is a specialized ActiveX object that integrates into the VB environment. You saw another example of an ActiveX Designer, the IIS application, in Chapter 28, "Using ActiveX Data Objects (ADO)."
In this section, you'll create a sample Data Report based on a query of the BIBLIO database. To create this report, perform the following steps:
1. Set up the ADO recordset to be used by the report.
2. Add a DataReport object to the Visual Basic project.
3. Design the report by placing fields on the DataReport designer form.
4. Write code to display the report in the program.
Setting Up the Data Source
To begin the sample project, open Visual Basic and start a new Standard EXE project. The next step in creating the sample report has nothing to do with the report itself, but rather the data that goes into the report. Before you can design a report, you have to know what you are reporting. Therefore, you can build on the ADO knowledge you acquired from Chapter 28 and create a simple query that can be used for the DataSource property of the report.
sarrow.gifSee "Setting up a Data Source," p. 613
Refer to Chapter 28 if necessary to perform these steps to create the query:
1. Add the reference for Microsoft ActiveX Data Objects to your project.
2. If you have not already set up the BIBLIO ODBC data source, do so now.

 
< previous page page_642 next page >